/**
 *  @author yinghui.zhang  用户帐号管理
 */
 
Ext.ns("cn.hls.web.action.dict.person");
var userAccountForm  = cn.hls.web.action.dict.person.UserAccountForm; 
Ext.apply(Ext.form.VTypes, {
	checkpwd : function(val, field) {
		var newpass =  Ext.getDom('a_password').value;
		if(newpass != val){
			field.vtypeText = "两次输入密码不一致！" ;
			return false;
		}
		return true;
	}
});

userAccountForm = function() {
	var  accountwin, accountPanel;
	return {
		
		createAccountFormPanel : function(){
			accountPanel =  new Ext.form.FormPanel({
							id : 'accountPanel',
							name : 'accountPanel',
							labelAlign : 'right',
							labelWidth : 65,
							padding : "10",
							defaultType : 'textfield',
							defaults : {
									anchor : '90%'
							},
							items : [{
								fieldLabel : '用户账号',
								id:'loginName',
								name : 'loginName',
								allowBlank : false,
								readOnly:true
							}, {
								fieldLabel : '用户密码',
								id:'a_password',
								name : 'password',
								inputType : 'password',
								allowBlank : false
							},{
								fieldLabel : '确认密码',
								id:'a_againpass',
								inputType : 'password',
								vtype : 'checkpwd',
								allowBlank : false
							}, {
								id : 'id',
								name : 'id',
								hidden : true
							}]
				});
			return accountPanel;
		},
		
		createAccountWindow : function(){
		    accountwin = new ExtWin({
					    width : 320,
					    height : 170,
					    items : accountPanel,
						buttons : [
							{
								text : '保存',
								iconCls : 'acceptIcon',
								handler : function() {
									var f = accountPanel.getForm();
									if (f.isValid()){
										 accountPanel.form.submit({
											url : cfg.cxt+'/user/updatePwd.action',
											waitTitle : '提示',
											method : 'POST',
											waitMsg : '正在处理数据,请稍候...',
											success : function(form, action) {
												var  r = action.result.status;
												if(r==200){
												accountwin.hide();
												form.reset();
												}
											    Ext.Mytip.msg('提示', action.result.info);
											    
											},
				                            failure : bangni.sumbitError
										});
									}
								}
							}, {
								text : '关闭',
								iconCls : 'deleteIcon',
								handler : function() {
									accountwin.hide();
								}
							} ]
				   });
			 return  accountwin;
		}
	}
}();

